package com.injurydetection.www.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.injurydetection.www.R;
import com.injurydetection.www.view.ExamineFragment;

/**
 * Created by sunguiyong on 2020/8/14
 */
public class CreateNewDialog extends Dialog {
    private TextView cancel, commit;

    public void setCommitListener(CommitListener commitListener) {
        mCommitListener = commitListener;
    }

    public CommitListener getCommitListener() {
        return mCommitListener;
    }

    private CommitListener mCommitListener;
    public CreateNewDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_create_new, null);
        cancel = view.findViewById(R.id.cancel);
        commit = view.findViewById(R.id.commit);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                //TODO
                getCommitListener().commit();
            }
        });
        setContentView(view);

    }

    protected CreateNewDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public interface CommitListener{
        void commit();
    }
}
